{% extends "index.html" %}

{% block content %}
	<div class="col-xs-3 col-sm-3">
	</div>
	<div class="col-xs-6 col-sm-6 widget-container-span">
		<div class="widget-box">
			<div class="widget-header widget-header-large">
					<h4>
						<i class="icon-edit"></i>
						添加管理主机
					</h4>

					<div class="widget-toolbar">
					<a href="#" data-action="settings">
						<i class="icon-cog"></i>
					</a>

					<a href="#" data-action="reload">
						<i class="icon-refresh"></i>
					</a>

					<a href="#" data-action="collapse">
						<i class="icon-chevron-up"></i>
					</a>

					<a href="#" data-action="close">
						<i class="icon-remove"></i>
					</a>
					</div>
			</div>

		<div class="widget-body">
			<div class="widget-main">
					<form role="form" method="post" id="addHost" class="main form-horizontal">{% csrf_token %}
					
						<fieldset>

						<div class="form-group" >
							 <label class="col-sm-2 control-label">主机名*</label>
							 <div class="col-sm-6">
							 	<input type="text" class="form-control" name="hostname" placeholder="hostname" value="" title="请输入主机名称"  class="input-xlarge" required/>
							 </div>
						</div>
						
						<div class="form-group" >
							 <label class="col-sm-2 control-label">主机地址*</label>
							 <div class="col-sm-6">
							 	<input type="text" class="form-control" name="server_ip" placeholder="Ip Address" value="" pattern="^(\d+\.\d+\.\d+\.\d+|[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?))$" title="请输入IP地址或者域名"  class="input-xlarge" required/>
							 </div>
						</div>				
						<div class="form-group" >
							 <label class="col-sm-2 control-label">虚拟化类型*</label>
							 <div class="col-sm-6">
								<select id="pool_type" name="vm_type" onchange="javascript:oBtLibvirtTypeSelect();">
									<option value="1">TCP</option>
									<option value="2">SSH</option>	
									<option value="3">TLS</option>	
									<option value="4">SOCKET</option>								
								</select>	
							 </div>
						</div>
						
						<div class="form-group" style="display: none;" id="username">
							<div class="form-group">
								 <label class="col-sm-2 control-label">&nbsp;用户*</label>
								 <div class="col-sm-6">
								 <input type="text" class="form-control" name="username" placeholder="root"  class="input-xlarge" value="" />
								 </div>
							</div>							
	
						
							<div class="form-group">
								 <label class="col-sm-2 control-label">&nbsp;密码*</label>
								 <div class="col-sm-6">
								 <input type="password" class="form-control" name="passwd" placeholder="root"  class="input-xlarge" value="" />
								 </div>
							</div>							
						</div>						
						
					
						</fieldset>
						<legend></legend>
						<div class="form-group">
						<label class="col-sm-3 control-label"></label>
						<button type="button" id="add_host_submit" onclick="repealFromVaule(this)" class="btn btn-danger" >撤销操作</button>
				 		<button type="submit" class="btn btn-primary" >确认提交</button>
				 		</div>
				 		
					</form>	
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div><!-- /.page-content -->
			
<script type="text/javascript"> 

{% if errorInfo %}
	window.wxc.xcConfirm('{{errorInfo}}', window.wxc.xcConfirm.typeEnum.error);
{% endif %}
	
	   function oBtLibvirtTypeSelect() {
		   var obj = document.getElementById("pool_type"); 
		   var index = obj.selectedIndex;
		   var value = obj.options[index].value; 
		   if (value=="2"){
			   document.getElementById("username").style.display="";
		   }
		   else if (value=="3"){
			   document.getElementById("username").style.display="";   
		   }	
		   else {
			   document.getElementById("username").style.display="none";   
		   }		   
	   }
	
</script> 		
			
{% endblock %}

